<template>
	<div class="page_ad">
		<div class="ad" v-for="(o, i) in list_new" :key="i" >
			<img :src="o.img" style="width:100%;" />
		</div>
	</div>
</template>

<script>
	export default {
		props: {
			location: {
				type: String,
				default: "顶部广告"
			}
		},
		data(){
			return {
				list: []
			}
		},
		methods: {
			get_ad() {
				this.$get("~/api/ad/get_list?", {
					"page": 1,
					"size": "0"
				}, (json) => {
					if (json.result) {
						this.list = json.result.list
					}
				})
			}
		},
		computed:{
				list_new(){
					var location_name = vm.location;
					var location = this.location;
					return this.list.filter(function(o){
							return o[location_name] === location
					})
				}
		},
		created() {
			this.get_ad()
		}
	}
</script>

<style scoped="">
	.page_ad {
		overflow: hidden;
	}
</style>
